const app = getApp()
var request_api = require('../../../utils/require_api.js')
Component({
  data: {
    starCount: 0,
    forksCount: 0,
    visitTotal: 0,
    userInfo:null,
    show:false,
    showinfo: {
     
    },
  },
  methods: {
    //管理微信地址信息
    go_address() {
      wx.chooseAddress({
        success: (res) => {
          wx.setStorage({
            key: 'address',
            data: res,
            success() {
            }
          })

        },
        fail: function (err) {
          console.log(err)
        }
      })
    },

    //跳转充值页面
    go_insertmoney() {
      wx.navigateTo({
        url: '../my_wallet/my_wallet',
      })
    },
//跳转查看消息界面
    Message_notification(){
      wx.navigateTo({
        url: '../notice/notice',
      })
    }, 

    //查看个人资料
    personinfo(){
      this.setData({
        show:true
      })
    },
    onLoad(options) {
      let that = this;
      var avatarUrl='';      
      if (app.globalData.userInfo.avatarUrl!=''){
          avatarUrl= app.globalData.userInfo.avatarUrl;
        }
        that.setData({
          avatarUrl: avatarUrl,
          userInfo: app.globalData.userInfo
        });
      //获取用户信息
      request_api.request(
        'select_openiduser', //需要传给wxrequest.js 的 url
        {
          "openid": app.globalData.openid
        }, //需要传的 data
        function (res) {
          that.data.showinfo=res.data;
         that.setData({
           showinfo: that.data.showinfo
         })
        },
        function () {
          console.log("錯誤");
        },
      )
    },

    onShow() {
      var that = this;
      request_api.request(
        'get_announcement', //需要传给wxrequest.js 的 url
        {
          user_id: app.globalData.openid,
          if_read: 0
        }, //需要传的 data
        function (res) {
          that.setData({
            noticenum:res.data.length
          })
        }
      )
    },
   
    daifukuan(){
      wx.navigateTo({
        url: '../orderdetails/orderdetails?activity=' + 1,
      })
    },
    daifahuo(){
      wx.navigateTo({
        url: '../orderdetails/orderdetails?activity='+2,
      })
    },
    daishouhuo(){
      wx.navigateTo({
        url: '../orderdetails/orderdetails?activity=' + 3,
      })
    },

    gotoorders(e) {
      wx.navigateTo({
        url: '../orderdetails/orderdetails',
      })
    },
    showModal(e) {
      this.setData({
        modalName: e.currentTarget.dataset.target
      })
    },
    hideModal(e) {
      this.setData({
        modalName: null
      })
    },
    //退货管理
    tuihuo(){
      wx.navigateTo({
        url: '../return_good/return_good',
      })      
    },
  },
})